package com.yiwei.hdb.api.requestInfo;

import com.yiwei.hdb.api.Api;
import com.yiwei.hdb.api.callback.LoanRecordContract;
import com.yiwei.hdb.util.Network;
import com.yiwei.hdb.util.RxLifeUtil;
import com.yiwei.hdb.util.ToastUtil;

/**
 * Created by Administrator on 2017/5/14.
 */

public class LoanRecordRequest extends BaseRequest<LoanRecordContract.View> implements LoanRecordContract.Presenter<LoanRecordContract.View> {

    public static LoanRecordRequest create() {
        return new LoanRecordRequest();
    }


    @Override
    public void getLoanRecordInfo() {
        if (!Network.checkNetwork(BaseContext)) {
            ToastUtil.makeText(BaseContext, networkFail);
            return;
        }
        mView.onRequestStart();
        Api.api_service.getLoanRecordInfo().compose(RxLifeUtil.checkOn(BaseContext)).
                doFinally(() -> {
                    try {
                        mView.complete();
                    } catch (NullPointerException e) {

                    }
                }).
                subscribe(result -> {
                    mView.getLoanRecordInfoSuccess(result);
                });
    }
}
